
/*
 *
 * All Rights Reserved.
 */
package com.model.demo.designmodel.proxy.dbroute;

/**
 * DynamicDataSourceEntity
 *
 * @author Liao Dongshan, 2019年06月04日
 *
 */
public class DynamicDataSourceEntity {
    public final static String DEFAULT_SOURCE=null;
    private DynamicDataSourceEntity(){

    }
    private static ThreadLocal<String> local=new ThreadLocal<>();
    public static String get(){
        return local.get();
    }
    public static void  set(String source){
        local.set(source);
    }

    public static void set(int year){
        local.set("DB_"+year);
    }

    public static void restore(){
        local.set(DEFAULT_SOURCE);
    }
}
